<template>
  <XmSelect v-model="inputValue" :options="warehouselist" :config="{
    labelKey: 'name',
    valueKey: 'id'
  }" v-bind="{
    ...$attrs,
    placeholder: $attrs.placeholder || '请选择'
  }" v-on="$listeners">
  </XmSelect>
</template>

<script>
import inputValueMixin from '@/mixins/inputValueMixin'
import { getWarehouseListCityIds } from "@/api/pending"
const cityId = localStorage.getItem("saber-areaId") ? JSON.parse(localStorage.getItem("saber-areaId")).content : undefined
const defaultParams = {
  cityId: cityId
}
export default {
  name: 'WarehouseSelect',
  mixins: [inputValueMixin],
  props: {
    needInitData: {
    }
  },
  data() {
    return {
      warehouselist: []
    };
  },
  methods: {
    getWarehouseList(params = defaultParams) {
      getWarehouseListCityIds(params).then(
        (res) => {
          this.warehouselist = res.data.data;
        }
      );
    },
  },
  created() {
    if (this.needInitData) {
      this.getWarehouseList()
    }
  }
};
</script>

<style scoped lang="scss">
</style>
